package user;

import book.Book;
import book.BookList;

import java.util.Scanner;

/**
 * Created by cc
 * Description:
 * User: CZH
 * Date: 2022-09-23
 * Time: 21:28
 */
public class Main {

    //登录方法
    public static User login(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名: ");
        String name = scanner.nextLine();
        System.out.println("请输入你的身份: 1(管理员) 2(普通用户)");
        int choice = scanner.nextInt();

        //多态，根据用户选择而创建相应的类型
        if (choice == 1) {
            return new AdiminUser(name);
        }else {
            return new NormalUser(name);
        }
    }


    //测试类
    public static void main(String[] args) {
        //生成顺序表
        BookList bookList = new BookList();
        //根据用户的选择创建响应的用户类
        User user = login();

        while (true) {
            //用户选择要操作的功能
            int choice = user.menu();
            //根据选择choice对顺序表bookList操作。
            user.doOperation(choice, bookList);
        }
    }
}
